﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;
//using Common.Utilities;

namespace WebSurvey
{
    public class Ajax : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            string result = string.Empty;
            string request = string.Empty;
            string userName = "g";
            try
            {
                using (StreamReader reader = new StreamReader(context.Request.InputStream))
                {
                    request = reader.ReadToEnd();
                }
                switch (context.Request.QueryString["action"])
                {
                    case "getSurveyData":
                     //   result = GeneralHelper.ObjectToJson(Bl.GetSurveyData(userName));
                        break;
                    case "goToProcess":
                       // result = GeneralHelper.ObjectToJson(Bl.GoToProcess(userName, GeneralHelper.JsonToObject<SurveyData>(request)));
                        break;
                    case "saveProcess":
                      //  result = GeneralHelper.ObjectToJson(Bl.SaveProcess(userName, GeneralHelper.JsonToObject<Process>(request)));
                        break;
                }
            }
            catch(Exception ex)
            {
                //result = GeneralHelper.ObjectToJson( new ReqRes<string> { Message = ex.ToString() } );
            }
            context.Response.Write(result);
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }


    }
}